package lol.clann.minecraft.springboot.api.bukkit.rawmessage;

import relocate.com.fasterxml.jackson.databind.node.JsonNodeFactory;
import relocate.com.fasterxml.jackson.databind.node.ObjectNode;
import lol.clann.minecraft.springboot.api.model.ClickCallback;

/**
 * @author pyz
 * @date 2018/8/18 上午11:03
 */
public class MessageEvent {

    private String action;
    private Object value;
    private ClickCallback clickCallback;

    public MessageEvent(String action, Object value) {
        this.action = action;
        this.value = value;
    }

    public MessageEvent setClickCallback(ClickCallback clickCallback) {
        this.clickCallback = clickCallback;
        return this;
    }

    public ClickCallback getClickCallback() {
        return clickCallback;
    }

    /**
     * @return A {@link ObjectNode} representing the properties of this {@link MessageEvent}
     */
    public ObjectNode toJSON() {
        ObjectNode obj = JsonNodeFactory.instance.objectNode();
        obj.put("action", action);
        obj.put("value", value.toString());
        return obj;
    }

    /**
     * @return The action
     */
    public String getAction() {
        return action;
    }

    /**
     * @param action The action to set
     */
    public void setAction(String action) {
        this.action = action;
    }

    /**
     * @return The value
     */
    public Object getValue() {
        return value;
    }

    /**
     * @param value The value to set
     */
    public void setValue(Object value) {
        this.value = value;
    }
}
